-if @status
  .span-20 
    %h2 Downloading:
  .span-4.last 
    update in:
    %b#updatecount
    %a#canceltmo{:href=>"#"} (stop)
  .span-24.border-title
    .span-8 URL
    .span-5 Progress
    .span-2 Speed
    .span-2 Percent
    .span-3 Size
    .span-2 Time
    .span-2.last ETA
- i=0
- @status["downloading"].each do |k,v|
  - v.each do |stat|
    - if i%2 !=0
      .span-24.odd
    -else
      .span-24.even    
        -lnk=stat["link"].resume(40)
        .span-8{:id=>"link_#{stat["id"]}"}
          ="#{k.to_s} - #{lnk}"
        -if stat["wait"]>0 or stat["status"]==:init
          -if stat["status"]==:init
            .span-16.last 
              init...
          -else
            .span-16.last 
              Waiting:
              %b.wait{:id=> "wait_#{stat['id']}"}
                = stat["wait"].to_s
        -else
          .span-5              
            .progressbar{:id=>"prog#{i.to_s}"}
            :javascript
              $("#prog#{i.to_s}").progressbar({ value: #{stat["progress_percent"].floor} });
          .span-2
            =stat["speed"]
          .span-2 
            = "%6.2f%%"%stat["progress_percent"]
          .span-3
            ="#{stat["total"]}/#{stat["size"]}"
          .span-2
            =stat["time"]
          .span-2.last
            =stat["eta"]
      -i=i+1

.span-24
  %h2 Queued:
-i=0
-@status["links"].each do |k,v|
  -v.each do |stat|
    -if i%2 !=0
      .span-24.odd
    -else
      .span-24.even
        =stat["link"]    
    -i=i+1

.span-24
  %h2 Downloaded:
-i=0
-@status["downloaded"].each do |k,v|
  -v.each do |stat|
    -if i%2 !=0
      .span-24.odd
    -else
      .span-24.even
        =stat["link"]    
    -i=i+1

.span-24
  %h2 Not Downloaded:
-i=0
-@status["notdownloaded"].each do |k,v|
  -v.each do |stat|
    -if i%2 !=0
      .span-24.odd
    -else
      .span-24.even
        =stat["link"]    
    -i=i+1

-ww=''
-@status["downloading"].each do |k,v|
  -v.each do |stat|
    -ww=ww+"w.push($(\"#wait_#{stat["id"].to_s}\"));"

:javascript
  var count= 10;
  var c=count;
  var tmo;
  $("#updatecount").text(c);
  function counter(){
    $("#updatecount").text(c);
    var w = []
    #{ww}
    $.each(
      w,
      function( intIndex, objValue ){
        n=parseInt(objValue.text());
        if(n>0)
          objValue.text(n-1);
      }
    );
    if (c>0){
      c=c-1;
    }
    if(c==0){
      clearTimeout ( tmo );
      getstatus();
    }
  };
  clearTimeout ( tmo );
  tmo=setInterval( "counter()", 1000 );
  $("#canceltmo").click(function(){
    if ($("#canceltmo").text()=="(stop)"){
      $("#canceltmo").text("(resume)")
      clearTimeout ( tmo );
    }else{
      $("#canceltmo").text("(stop)")
      tmo=setInterval( "counter()", 1000 );
    }    
  });